package com.ssyc.gsk_master.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.ssyc.gsk_master.R;
import com.ssyc.gsk_master.bean.GetRedInfo;

import java.util.List;

/**
 * 红包列表的适配器
 * Created by Administrator on 2018/7/23 0023.
 */

public class RedDetailsRvAdapter extends BaseQuickAdapter<GetRedInfo.RedPacketsBean.PersonsBean, BaseViewHolder> {

    private Context context;

    public RedDetailsRvAdapter(Context context, int layoutResId, @Nullable List<GetRedInfo.RedPacketsBean.PersonsBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, GetRedInfo.RedPacketsBean.PersonsBean item) {
        //头像
        RoundedImageView ivHead = helper.getView(R.id.iv_head);
        ivHead.setImageResource(R.drawable.master_red_pacaget);

        //领取的人
        TextView tvName = helper.getView(R.id.tv_content);
        tvName.setText(item.getCustomer());

        //时间
        TextView tvTime = helper.getView(R.id.tv_time);
        tvTime.setText(item.getGetDate());

        //红包金额
        TextView tvMoney = helper.getView(R.id.tv_money);
        tvMoney.setText(item.getMoney() + "");

        //是否领取过的标识
        if (!"1".equals(item.getStatus())) {
            tvName.setTextColor(context.getResources().getColor(R.color.red_gray));
            tvMoney.setTextColor(context.getResources().getColor(R.color.red_gray));
        } else {
            tvName.setTextColor(context.getResources().getColor(R.color.red_black));
            tvMoney.setTextColor(context.getResources().getColor(R.color.red_black));
        }
    }
}
